<?php
include ('../../__global.php');
class aj_suggest_collect extends ml_controller {
    private $content;
    function initParam() {
        $this->content = $this->input ( 'content', 'P', '' );
        $this->content = preg_replace ( '/\s+/', '_', $this->content );
    }
    function checkParam() {
        if (empty ( $this->content )) {
            $this->api_output ( ML_RCODE_PARAM );
        }
    }
    function main() {
        if (ml_tool_ua::is_fake_visitor ()) {
            $this->api_output ( ML_RCODE_FAIL );
        } else {
            $_controller = ml_factory::get_controller ();
            $wbinfo = $_controller->loginProxy ( 'getWeiboInfo' );
            if(!$wbinfo['weiboID']){
                $wbinfo = $_controller->loginProxy('ssoUserInfo');
                $wbinfo = $_controller->loginProxy('getWeiboInfo');
            }
            $wb_uid = $wbinfo ['weiboID'];
            $data = array (
                    'time' => time (),
                    'ip' => Tool_ip::get_real_ip (),
                    'uid' => $this->__visitor ['uid'] ? $this->__visitor ['uid'] : 0,
                    'wb_uid' => $wb_uid ? $wb_uid : 0,
                    'usign' => ml_tool_ua::get_usign (),
                    'content' => $this->content,
                    'localip' => Tool_ip::getLocalLastIp () ,
                    'referer'=>$_SERVER['HTTP_REFERER']
            );
            $res = ml_tool_sendMq::suggest_collect ( $data );
            if ($res)
                $this->api_output ( ML_RCODE_SUCC );
        }
    }
}

new aj_suggest_collect ();